package com.File;
import java.io.File;
import java.io.IOException;
public class Main34 {
    public static void main(String[] args) throws IOException {
        File oldName=new File("D:\\ex01\\Java\\src\\com\\File\\Main30.java");
        File newName=new File("D:\\ex01\\Java\\src\\com\\File\\Main34.java");
        if(newName.exists()){
            throw new java.io.IOException("file exists");
        }
        if(oldName.renameTo(newName)){
            System.out.println("文件重命名成功");
        }else{
            System.out.println("文件重命名失败");
        }
    }
}
